package org.light.verb;

import java.util.ArrayList;
import java.util.List;

import org.light.core.Verb;
import org.light.core.Writeable;
import org.light.domain.Domain;
import org.light.domain.JavascriptBlock;
import org.light.domain.JavascriptMethod;
import org.light.domain.Method;
import org.light.domain.Signature;
import org.light.domain.Statement;
import org.light.domain.Type;
import org.light.easyui.EasyUIPositions;
import org.light.exception.ValidateException;
import org.light.utils.MybatisSqlReflector;
import org.light.utils.StringUtil;
import org.light.utils.WriteableUtil;

public class FindFullInfoById extends Verb implements EasyUIPositions {

	@Override
	public Method generateDaoImplMethod() throws Exception{
		if (this.denied)
			return null;
		else {
			Method method = new Method();
			method.setStandardName(
					"find" + this.domain.getStandardName() + "FullInfoBy" + this.domain.getDomainId().getCapFirstFieldName());
			method.setNoContainer(true);
			List<Writeable> list = new ArrayList<Writeable>();
			list.add(new Statement(100L, 1,
					"<select id=\"" + StringUtil.lowerFirst(this.getVerbName()) + "\" parameterType=\""
							+ this.domain.getDomainId().getClassType() + "\" resultMap=\""
							+ this.domain.getLowerFirstDomainName() + "\">"));
			list.add(new Statement(200L, 2, MybatisSqlReflector.generateFindByIdStatement(domain)));
			list.add(new Statement(300L, 1, "</select>"));
			method.setMethodStatementList(WriteableUtil.merge(list));
			method.setMethodStatementList(WriteableUtil.merge(list));
			return method;
		}
	}

	@Override
	public Method generateDaoMethodDefinition() throws Exception{
		if (this.denied)
			return null;
		else {
			Method method = new Method();
			method.setStandardName(
					"find" + this.domain.getStandardName() + "FullInfoBy" + this.domain.getDomainId().getCapFirstFieldName());
			method.setReturnType(
					new Type(this.domain.getCapFirstDomainNameWithSuffix(), this.domain.getPackageToken()));
			method.addAdditionalImport("java.util.List");
			method.addAdditionalImport(this.domain.getPackageToken() + "." + this.domain.getDomainSuffix() + "."
					+ this.domain.getCapFirstDomainNameWithSuffix());
			method.addSignature(new Signature(1, this.domain.getDomainId().getFieldName(),
					this.domain.getDomainId().getClassType()));
			method.setThrowException(true);
			return method;
		}
	}

	@Override
	public String generateDaoImplMethodString() throws Exception{
		if (this.denied)
			return null;
		else {
			return generateDaoImplMethod().generateMethodString();
		}
	}

	@Override
	public String generateDaoMethodDefinitionString() throws Exception{
		if (this.denied)
			return null;
		else {
			return generateDaoMethodDefinition().generateMethodDefinition();
		}
	}

	@Override
	public String generateDaoImplMethodStringWithSerial() throws Exception{
		if (this.denied)
			return null;
		else {
			Method m = this.generateDaoImplMethod();
			m.setContent(m.generateMethodContentStringWithSerial());
			m.setMethodStatementList(null);
			return m.generateMethodString();
		}
	}

	@Override
	public Method generateServiceMethodDefinition() throws Exception{
		return null;
	}

	@Override
	public String generateServiceMethodDefinitionString() throws Exception{
		return null;
	}

	@Override
	public Method generateServiceImplMethod() throws Exception{
		return null;
	}

	@Override
	public String generateServiceImplMethodString() throws Exception{
		return null;
	}

	@Override
	public String generateServiceImplMethodStringWithSerial() throws Exception{
		return null;
	}

	public FindFullInfoById(){
		super();
		this.setLabel("查找全部信息");
	}
	
	public FindFullInfoById(Domain domain) throws ValidateException{
		super();
		this.domain = domain;
		this.denied = domain.isVerbDenied("Clone");
		this.setVerbName("Find"+StringUtil.capFirst(this.domain.getStandardName())+"FullInfoBy"+this.domain.getDomainId().getCapFirstFieldName());
		this.setLabel("查找全部信息");
		if  (domain.getLanguage().equalsIgnoreCase("english"))  this.setLabel("FindFullInfoById");
	}

	@Override
	public Method generateControllerMethod() throws Exception{
		return null;
	}

	@Override
	public String generateControllerMethodString() throws Exception{
		return null;
	}

	@Override
	public String generateControllerMethodStringWithSerial() throws Exception{
		return null;
	}

	@Override
	public JavascriptBlock generateEasyUIJSButtonBlock() throws Exception {
		return null;
	}

	@Override
	public String generateEasyUIJSButtonBlockString() throws Exception {
		return null;
	}

	@Override
	public String generateEasyUIJSButtonBlockStringWithSerial() throws Exception {
		return null;
	}

	@Override
	public JavascriptMethod generateEasyUIJSActionMethod() throws Exception {
		return null;		
	}

	@Override
	public String generateEasyUIJSActionString() throws Exception {
		return null;
	}

	@Override
	public String generateEasyUIJSActionStringWithSerial() throws Exception {
		return null;
	}
}
